package mulegame;
/**
 * Map class initializes the Map, and tileGrid objects, creates Maps, determines which map to make, can get 
 * information about a tile and has a toString
 * 
 * @author Area 29
 *
 */

public class Map {

	private int mapType;
	private Tile[][] tileGrid;

	// tileGrid[row][col]
	/**
	 * initializes mapType and tileGrid object according to parameter and sets calls makeMap
	 * 
	 * @param type type of tile
	 */
	public Map(int type) {
		mapType = type;
		tileGrid = new Tile[5][9];
		this.makeMap(mapType);
	}
	/**
	 * displays the map with correct image paths linked to each tile along with whether there is a mule on it 
	 * and checks whether the tile is owned. 
	 * @param definition array of strings that hold all the tile types
	 * @param eng game engine object
	 */
	public Map(String[] definition, GameEngine eng){
	    String[] args;
	    tileGrid = new Tile[5][9];
	    int row = -1;
	    int col = 0;
	    TileType currTileType = null;
	    Mule currMule = null;
	    for(String line : definition){
	        args = line.split("\\s:\\s");
	        if(args[0].equals("Type")){
	            row++;
	            if(row >= 9){
	                 col++;
	                 row = 0;
	            }
	            switch(Integer.parseInt(args[1])){
	            case 0:
	                currTileType = TileType.PLAIN;
	                break;
	            case 1:
	                currTileType = TileType.RIVER;
	                break;
	            case 2:
	                currTileType = TileType.M1;
	                break;
	            case 3:
	                currTileType = TileType.M2;
	                break;
	            case 4:
	                currTileType = TileType.M3;
	                break;
	            case 5:
	                currTileType = TileType.TOWN;
	                break;
	            default:
	                Logger.println("Unknown tile type in Map(String)");
	                break;
                        
	            }
	            tileGrid[col][row] = new Tile(currTileType);
	            tileGrid[col][row].setImagePath(args[2]);
	        }
	        if(args[0].equals("Mule")){
	            switch(Integer.parseInt(args[1])){
	            case 1:
	                currMule = Mule.FOOD;
	                break;
	            case 2:
	                currMule = Mule.ENERGY;
	                break;
	            case 3:
	                currMule = Mule.ORE;
	                break;
	            default:
	                Logger.println("Unknown mule type in Map(String)");
	                break;
	            }
	            tileGrid[col][row].placeMule(currMule);
	        }
	        if(args[0].equals("Owner")){
	             tileGrid[col][row].setOwned(eng.lookupPlayerByName(args[1])); 
	        }
	    }
	}
   /**
    * Determines whether to make Standard Map or Custom Map based on parameter
    * 
    * @param type type of map
    */
	private void makeMap(int type) {
		switch (type) {
		// all make Map functions at the bottom
		case 0:
			this.makeStandardMap();
			break;
		case 1:
			this.makeCustomMap1();
			break;
		case 2:
			this.makeCustomMap2();
			break;
		case 3:
			this.makeCustomMap3();
			break;
		case 4:
			this.makeCustomMap4();
			break;
		case 5:
			this.makeCustomMap5();
			break;
		}
	}

	/**
	 * returns grid array of tiles
	 * 
	 * @return tileGrid grid array of tiles
	 */
	public Tile[][] getTileGrid() {
		return tileGrid;
	}
    /**
     * Updates tile terrain type if it's within the map's boundaries
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @param t tile
     * @return true
     */
	public boolean setTileType(int x, int y, TileType t) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			tileGrid[x][y].updateTerrainType(t);
			return true;
		} else {
			return false;
		}
	}
	/**
	 * returns tile terrain type if it's within the map's boundaries
	 * 
	 * @param x x coord of tile
	 * @param y y coord of tile
	 * @return tileGrid[x][y].getTerrainType()
	 */
	public TileType getTileType(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].getTerrainType();
		} else {
			return null;
		}
	}
	/**
     * returns tile object if it's within the map's boundaries at specified location
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @return tileGrid[x][y]
     */
	public Tile getTile(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y];
		} else {
			return null;
		}
	}
	/**
     * returns true if mule is placed successfully on specified location within map boundaries
     * 
     * @param x
     * @param y
     * @return tileGrid[x][y].placeMule()
     */	
//	public boolean placeMule(int x, int y) {
//		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
//			return tileGrid[x][y].placeMule();
//		} else {
//			return false;
//		}
//	}
	
	/**
     * returns true if mule is picked up successfully on specified location within map boundaries
     * 
     * @param x x coord of mule
     * @param y y coord of mule
     * @return tileGrid[x][y].pickUpMule() 
     */
	public boolean pickUpMule(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].pickUpMule();
		} else {
			return false;
		}
	}

	/**
	 *  Returns amount of food produced by a tile and -1 if out of bounds 
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @return tileGrid[x][y].getFoodProd()
     */
	public int getFoodProd(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].getFoodProd();
		} else {
			return -1;
		}
	}

	/**
	 *  Returns amount of energy produced by a tile and -1 if out of bounds 
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @return tileGrid[x][y].getEnergyProd()
     */
	public int getEnergyProd(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].getEnergyProd();
		} else {
			return -1;
		}
	}

	/**
	 *  Returns amount of ore produced by a tile and -1 if out of bounds 
     *  
     * @param x x coord of tile
     * @param y y coord of tile
     * @return tileGrid[x][y].getOreProd()
     */
	public int getOreProd(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].getOreProd();
		} else {
			return -1;
		}
	}

	/** 
	 * Returns the image path directory and null if out of bounds
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @return tileGrid[x][y].getImagePath()
     */
	public String getImagePath(int x, int y) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			return tileGrid[x][y].getImagePath();
		} else {
			return null;
		}
	}
	/** 
	 * Sets image path to specified string to change between with/out mule icon, returns false if out of bounds  
     * 
     * @param x x coord of tile
     * @param y y coord of tile
     * @param imageP image path of image
     * @return true
     */
	
	public boolean setImagePath(int x, int y, String imageP) {
		if (x < 5 && x >= 0 && y < 9 && y >= 0) {
			tileGrid[x][y].setImagePath(imageP);
			return true;
		} else {
			return false;
		}
	}
	
	/** 
	 * Makes the standard map with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. 
	 */
	private void makeStandardMap() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}
	
	
	/** 
	 * Makes custom map 1 with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. Currently all custom maps are standard maps.  
	 */
	private void makeCustomMap1() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}
	/** 
	 * Makes custom map 2 with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. Currently all custom maps are standard maps.  
	 */
	private void makeCustomMap2() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}
	/** 
	 * Makes custom map 3 with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. Currently all custom maps are standard maps.  
	 */
	private void makeCustomMap3() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}
	/** 
	 * Makes custom map 4 with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. Currently all custom maps are standard maps.  
	 */
	private void makeCustomMap4() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}
	/** 
	 * Makes custom map 5 with tileGrid[0][0] being the top-left Tile of the Map in tileGrid[row][column]
	 * format. Currently all custom maps are standard maps.  
	 */
	private void makeCustomMap5() {
		tileGrid[0][0] = new Tile(TileType.PLAIN);
		tileGrid[0][1] = new Tile(TileType.PLAIN);
		tileGrid[0][2] = new Tile(TileType.M1);
		tileGrid[0][3] = new Tile(TileType.PLAIN);
		tileGrid[0][4] = new Tile(TileType.RIVER);
		tileGrid[0][5] = new Tile(TileType.PLAIN);
		tileGrid[0][6] = new Tile(TileType.M3);
		tileGrid[0][7] = new Tile(TileType.PLAIN);
		tileGrid[0][8] = new Tile(TileType.PLAIN);
		tileGrid[1][0] = new Tile(TileType.PLAIN);
		tileGrid[1][1] = new Tile(TileType.M1);
		tileGrid[1][2] = new Tile(TileType.PLAIN);
		tileGrid[1][3] = new Tile(TileType.PLAIN);
		tileGrid[1][4] = new Tile(TileType.RIVER);
		tileGrid[1][5] = new Tile(TileType.PLAIN);
		tileGrid[1][6] = new Tile(TileType.PLAIN);
		tileGrid[1][7] = new Tile(TileType.PLAIN);
		tileGrid[1][8] = new Tile(TileType.M3);
		tileGrid[2][0] = new Tile(TileType.M3);
		tileGrid[2][1] = new Tile(TileType.PLAIN);
		tileGrid[2][2] = new Tile(TileType.PLAIN);
		tileGrid[2][3] = new Tile(TileType.PLAIN);
		tileGrid[2][4] = new Tile(TileType.TOWN);
		tileGrid[2][5] = new Tile(TileType.PLAIN);
		tileGrid[2][6] = new Tile(TileType.PLAIN);
		tileGrid[2][7] = new Tile(TileType.PLAIN);
		tileGrid[2][8] = new Tile(TileType.M1);
		tileGrid[3][0] = new Tile(TileType.PLAIN);
		tileGrid[3][1] = new Tile(TileType.M2);
		tileGrid[3][2] = new Tile(TileType.PLAIN);
		tileGrid[3][3] = new Tile(TileType.PLAIN);
		tileGrid[3][4] = new Tile(TileType.RIVER);
		tileGrid[3][5] = new Tile(TileType.PLAIN);
		tileGrid[3][6] = new Tile(TileType.M2);
		tileGrid[3][7] = new Tile(TileType.PLAIN);
		tileGrid[3][8] = new Tile(TileType.PLAIN);
		tileGrid[4][0] = new Tile(TileType.PLAIN);
		tileGrid[4][1] = new Tile(TileType.PLAIN);
		tileGrid[4][2] = new Tile(TileType.M2);
		tileGrid[4][3] = new Tile(TileType.PLAIN);
		tileGrid[4][4] = new Tile(TileType.RIVER);
		tileGrid[4][5] = new Tile(TileType.PLAIN);
		tileGrid[4][6] = new Tile(TileType.PLAIN);
		tileGrid[4][7] = new Tile(TileType.PLAIN);
		tileGrid[4][8] = new Tile(TileType.M2);
	}

   /**
    * Prints out data on Map and Tiles
    * 
    * @return desc string with data of tiles
    */
    
    public String toString(){
    	
    	//  What do we need to save
    	//		Map Type [Standard/Cust1...]
    	//		Tile Owners
    	//		Mule Type
    	
	    String desc = "Map Information";
	    desc += "\n";
	    
	    String saveMapType = "";
	    String saveTileOwner = "";
	    String saveMuleType = "";
	    
		switch (mapType) {
		case 0:
			saveMapType = "Standard";
			break;
		case 1:
			saveMapType = "CustomMap1";
			break;
		case 2:
			saveMapType = "CustomMap2";
			break;
		case 3:
			saveMapType = "CustomMap3";
			break;
		case 4:
			saveMapType = "CustomMap4";
			break;
		case 5:
			saveMapType = "CustomMap5";
			break;
        default:
            saveMapType = "UNKNOWN";
            Logger.println("Unknown map type encountered in Map's toString");
            break;
		}
        desc += "MapType : " + saveMapType + " : " + Integer.toString(mapType) + "\n";
        
        for(Tile[] row : tileGrid){
            for(Tile t : row){
                desc += t.toString();
            }
        }
        int lines = desc.split("\n").length;
        desc = "Lines : " + Integer.toString(lines) + "\n" + desc;
		/*
        for (int row=0; row < 5; row++)
        {
            for (int col=0; col < 9; col++)
            {
                Tile value = tileGrid[row][col];
                
                if (tileGrid[row][col].isOwned()) 
                	saveTileOwner = tileGrid[row][col].getOwner().getName();
                	desc += "Tile Grid Owner [" + row + "][" + col + "] : " + saveTileOwner + "\n";
                	
                if (tileGrid[row][col].hasMule())
                	saveMuleType = tileGrid[row][col].getMule().toString();      	
                    desc += "Tile Mule Type [" + row + "][" + col + "] : " + saveMuleType + "\n";
            }
        }
        */
		return desc;   
	}
}
